﻿@* 
Project: Aguafrommars/TheIdServer
Copyright (c) 2022 @Olivier Lefebvre
*@
@inject Microsoft.AspNetCore.Mvc.Localization.IViewLocalizer Localizer

@model Aguacongas.TheIdServer.Duende.Quickstart.Ciba.ViewModel

<div class="ciba-consent">
    <div class="lead">
        @if (Model.ClientLogoUrl != null)
        {
            <div class="client-logo"><img src="@Model.ClientLogoUrl" alt="client logo"></div>
        }
        <h1>
            @Html.Raw(string.Format(Localizer["{0} <small class=\"text-muted\">is requesting your permission</small>"].Value, Model.ClientName))
        </h1>
        
        <h3>@Localizer["Verify that this identifier matches what the client is displaying:"] <em  class="text-primary">@Model.BindingMessage</em></h3>

        <p>@Localizer["Uncheck the permissions you do not wish to grant."]</p>
    </div>

    <div class="row">
        <div class="col-sm-8">
            <partial name="_ValidationSummary" />
        </div>
    </div>

    <form asp-page="/Ciba/Consent">
        <input type="hidden" asp-for="Input.Id" />
        <div class="row">
            <div class="col-sm-8">
                @if (Model.IdentityScopes.Any())
                {
                    <div class="form-group">
                        <div class="card">
                            <div class="card-header">
                                <span class="glyphicon glyphicon-user"></span>
                                @Localizer["Personal Information"]
                            </div>
                            <ul class="list-group list-group-flush">
                                @foreach (var scope in Model.IdentityScopes)
                                {
                                    <partial name="_CibaScopeListItem" model="@scope" />
                                }
                            </ul>
                        </div>
                    </div>
                }

                @if (Model.ApiScopes.Any())
                {
                    <div class="form-group">
                        <div class="card">
                            <div class="card-header">
                                <span class="glyphicon glyphicon-tasks"></span>
                                @Localizer["Application Access"]
                            </div>
                            <ul class="list-group list-group-flush">
                                @foreach (var scope in Model.ApiScopes)
                                {
                                    <partial name="_CibaScopeListItem" model="scope" />
                                }
                            </ul>
                        </div>
                    </div>
                }

                <div class="form-group">
                    <div class="card">
                        <div class="card-header">
                            <span class="glyphicon glyphicon-pencil"></span>
                            @Localizer["Description"]
                        </div>
                        <div class="card-body">
                            <input class="form-control" placeholder="@Localizer["Description or name of device"]" asp-for="Input.Description" autofocus>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-4">
                <button name="Input.button" value="yes" class="btn btn-primary" autofocus>@Localizer["Yes, Allow"]</button>
                <button name="Input.button" value="no" class="btn btn-secondary">@Localizer["No, Do Not Allow"]</button>
            </div>
            <div class="col-sm-4 col-lg-auto">
                @if (Model.ClientUrl != null)
                {
                    <a class="btn btn-outline-info" href="@Model.ClientUrl">
                        <span class="glyphicon glyphicon-info-sign"></span>
                        <strong>@Model.ClientName</strong>
                    </a>
                }
            </div>
        </div>
    </form>
</div>